package view.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import controller.factory.AbstractFactory;

import model.User;

public class ActionLogin implements Action {

	@Override
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		User user = AbstractFactory.getNewInstance().getDAOUser()
				.findByName(username);
		if ((user != null) && (user.getPassword().equals(password))) 
			request.getSession().setAttribute("user", user);
			return "/secured/preparedSearch.do";
	}
}
